package com.game77.guessTheWords2.sprite;

import com.game77.guessTheWords2.core.GameSystem;
import com.wiyun.engine.nodes.Node;
import com.wiyun.engine.nodes.Sprite;

public class StarRate extends Node {
	Sprite star1;
	Sprite star2;
	Sprite star3;

	public StarRate() {
		star1 = Sprite.make(GameSystem.tex_star_full);
		star1.setPosition(-35, 0);
		addChild(star1);

		star2 = Sprite.make(GameSystem.tex_star_full);
		star2.setPosition(0, 0);
		addChild(star2);

		star3 = Sprite.make(GameSystem.tex_star_empty);
		star3.setPosition(35, 0);
		addChild(star3);
	}

	/**
	 * 设置得分
	 * 
	 * @param rate
	 * 
	 */
	public void setRate(float rate) {
		if (rate < 0.1f) {
			star1.setTexture(GameSystem.tex_star_empty);
			star2.setTexture(GameSystem.tex_star_empty);
			star3.setTexture(GameSystem.tex_star_empty);
		} else if (rate < 0.4f) {
			star1.setTexture(GameSystem.tex_star_full);
			star2.setTexture(GameSystem.tex_star_empty);
			star3.setTexture(GameSystem.tex_star_empty);
		} else if (rate < 0.8f) {
			star1.setTexture(GameSystem.tex_star_full);
			star2.setTexture(GameSystem.tex_star_full);
			star3.setTexture(GameSystem.tex_star_empty);
		} else {
			star1.setTexture(GameSystem.tex_star_full);
			star2.setTexture(GameSystem.tex_star_full);
			star3.setTexture(GameSystem.tex_star_full);
		}

	}
}
